home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-26 | 6.4 KB | 212 lines | [TEXT/ScoM] |
- ; Constructing Self-Oscillating Parallel Neurons
-
- ; Notes: This file implements a general way to feedback
- ; neurons and implement custom sequences the neurons
- ; can both recognise and fire. Examples on constructing
- ; parallel neural patterns are also shown here.
-
- ; Use melody,1 melody2 and melody3 to define instrument symbols.
-
- #| Oscillation Rules
-
- How to make a neuron which survises multiple oscillations?
- Self-oscillating neuron resembles oscillators build with
- electronic components. But as there are design principles
- for electronic oscillators there exist no rules for building
- neural oscillators.
-
- For this reason only some very general rules can be given,
- which will maximize the possibility to create self-oscillating
- neurons. The rest lies on your experimentations. Discovering
- self-oscillating neurons is like modelling the reticular
- activation center in the brain, which is used to control the
- wake/sleep activity. In at least a theoretical sense this
- device resembles a self-oscillating neuron, which feeds it
- output to all cortical areas, orchestrating them all to
- operate in a certain way, which will result 'consiciousness'.
- Succesful experimenting!
-
- Rule1:
- To prevent the neuron from stucking add noise to input patterns.
- This makes is sure that the neuron input will never be the
- same, and hence no loops will be formed.
-
- Rule2:
- Make the neuron fire symbols in range that the input rules
- can recognise. If the output symbols are in different range
- then rules cannot find any patterns to fire, and the otherwise
- option is used. To maximise feedback properties scale the
- otherwise output to a range the rules can handle. This ables
- the rules to recognise it in the next oscillation.
- |#
-
- ; Define two extension functions, one for feedbacking neurons
- ; and another to fire given sequences within neurons.
-
- (defun feedback-neuron (name n inputs)
- (let ((out nil) (collect nil))
- (dotimes (i n)
- (setq out (apply 'run-neuron (append (list name) inputs)))
- (push out collect)
- (setq inputs (append (cdr inputs) (list out))))
- (nreverse collect)))
-
- (defun pack-name (a b)
- (compress (append (explode a) '(-) (explode b))))
-
- (defun fire (&optional name sequence)
- (let ((out nil)
- (counter nil))
- (cond (sequence
- (cond ((equal sequence :reset)
- (set (pack-name 'counter name) 0))
- (t (set (pack-name 'seq name) (vector-to-list sequence))
- (set (pack-name 'counter name) 0)))
- t)
- (t (setq counter (eval (pack-name 'counter name)))
- (setq out (nth (mod counter (length (eval (pack-name 'seq name))))
- (eval (pack-name 'seq name))))
- (setq counter (1+ counter))
- (set (pack-name 'counter name) counter)
- out))))
-
- ; Define 3 fibonacci sequences.
-
- (fire 'fibonacci-seq1 (gen-fibonacci 6 'a 'b))
- (fire 'fibonacci-seq2 (gen-fibonacci 6 '-b '-c))
- (fire 'fibonacci-seq3 (gen-fibonacci 6 'b 'a))
-
- ; Define a neuron that fires fibonacci rules.
- ; Use this as a template for further modifications when
- ; building oscillating neurons.
-
- (def-neuron fibonacci-rule
- (in 1 'a) (fire 'fibonacci-seq1)
- (in 1 'b) (fire 'fibonacci-seq2)
- (otherwise (pick-random '(a b)))
- )
-
- ; Examine the following in the visualizer. There are interesting
- ; repetitions within the melody1 pattern. The melody1 pattern
- ; lenght is determined by the input pattern (a b c), and the
- ; the number of feedbacks (here 60). Experiment with different
- ; values.
-
- (setq melody1
- (flatten
- (feedback-neuron 'fibonacci-rule 60 '((a b c)))))
-
- ; Building 2nd melody line
-
- ; If you need more melody lines here is an example based on
- ; recognising fibonacci sequences. If the fibonacci sequence
- ; is found then the input pattern is shifted by 10, otherwise
- ; it is shifted by 5, and an output pattern is formed.
-
- (def-neuron fibonacci-modifier
- (in 1 (fire 'fibonacci-seq1)) (in 1 10)
- (otherwise (in 1 5))
- )
-
- ; reset fibonacci-seq before calculation
-
- (fire 'fibonacci-seq1 :reset)
-
- ; build 2nd melody
-
- (setq melody2 (run-neuron 'fibonacci-modifier melody1))
-
- ; Building 3rd melody line
-
- ; Here the 3rd melody line is calculated by finding a fibonacci
- ; sequence from input line 1, and a reversed fibonacci sequence
- ; from input line 2, and if both are found then the input line 1
- ; is shifted -3 to form the output, otherwise input line 2 is
- ; shifted by 3 to form the output.
-
- (def-neuron fibonacci-comparator
- (and (in 1 (fire 'fibonacci-seq1))
- (in 2 (fire 'fibonacci-seq3))) (in 1 -3)
- (otherwise (in 2 3))
- )
-
- ; reset sequences
-
- (fire 'fibonacci-seq1 :reset)
- (fire 'fibonacci-seq3 :reset)
-
- ; make the 3rd melody line comparing melody1 and melody3
-
- (setq melody3 (run-neuron 'fibonacci-comparator melody1 melody2))
-
- ; Additional Feedback
-
- ; The following seems to be able to produce further oscillations
- ; based on the melody1, melody2 and melody3. When examined in
- ; visualizer you notice a segment (size melody1) which repeats
- ; but is never quite same. The auditive could be interesting
- ; because these sequences should be able to be recognisable in
- ; auditive form, but each one is still different.
-
- ; reset sequences
-
- (fire 'fibonacci-seq1 :reset)
- (fire 'fibonacci-seq3 :reset)
-
- ; generate melody (may take some time...)
-
- (setq mel
- (flatten
- (feedback-neuron 'fibonacci-comparator 4 (list melody1 melody2 melody3))))
-
-
- #| How feedback-neuron operates?
-
- feedback-neuron enables to feed the output into the same
- neuron for further processing. In this version the inputs
- consist of any number of patterns. Each time the neuron
- is run the oldest input pattern is removed and the neuron
- output is added as a new input pattern. The output is
- also collected, and all the collections are then returned.
-
- The following shows what inputs a neuron gets at each
- iteration. Here three input patterns are initially supplied
- to the neuron and 5 iterations are produced.
-
- 1st iteration
- in1
- in2
- in3
-
- 2nd iteration
- in2
- in3
- out1
-
- 3rd iteration
- in3
- out1
- out2
-
- 4th iteration
- out1
- out2
- out3
-
- 5th iteration
- out2
- out3
- out4
-
- When finished the following collection of outputs is returned.
- Note that each output is a list, and you may use the output
- as input for another oscillating neuron. The ouput can also
- used directly to define the sections.
-
- --> ((out1) (out2) (out3) (out4))
- |#
-
- ; Use melody1, melody2, melody3 to define instruments. Redefine
- ; neuron rules to get more specific behaviour. The example shows
- ; just the basic principles of constructing neurons.
-